package com.dl.mall.controller.user;

import com.dl.mall.annotation.MethodInfo;
import com.dl.mall.entity.Brand;
import com.dl.mall.service.user.BrandService;
import com.dl.mall.utils.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 商品分区
 * @author DL
 * @create 2022-3-22 15:12:55
 */
@Slf4j
@RestController()
@RequestMapping("/category")
@Api(tags="分区类controller")
public class CategoryController {

    @Resource
    BrandService brandService;

    @ApiOperation(value="根据 分区 查询该分区所有品牌的信息")
    @MethodInfo
    @GetMapping(value = {"/{category}"})
    public Result getBrandByCategory(@PathVariable String category){
        System.out.println("category = " + category);

        List<Brand> brands = brandService.getBrandByCategoryId(category);
        System.out.println("brands = " + brands);
        if (brands != null){
            return Result.ok("查询分区品牌成功").data("brands", brands);
        }else {
            return Result.error("查询分区品牌失败");
        }
    }


}
